package com.mxpio.erp.common;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author : wpp
 * @Datetime : 2023/3/21 9:42
 * @Desc :
 * @Modor :  Modifytime:
 * @modDesc : Easyexcel 通用工具Listener类
 */
public class EasyexcelCommonListener<T> extends AnalysisEventListener<T> {
    private static final Logger LOGGER = LoggerFactory.getLogger(EasyexcelCommonListener.class);
    List<T> list = new ArrayList<>();

    public EasyexcelCommonListener() {
    }

    public void invoke(T data, AnalysisContext analysisContext) {
        this.list.add(data);
    }

    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        LOGGER.info("所有数据解析完成！");
    }

    public List<T> getList() {
        return this.list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }
}

